package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.Process;
import com.qidianit.mes.pojo.pro.ProcessStep;
import com.qidianit.mes.pro.mapper.ProcessMapper;
import com.qidianit.mes.pro.mapper.ProcessStepMapper;
import com.qidianit.mes.pro.service.ProcessService;
import com.qidianit.mes.pro.service.ProcessStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/17 0017 - 16:10
 */
@Service
public class ProcessStepServiceImpl implements ProcessStepService {

    @Autowired
    private ProcessStepMapper processStepMapper;


    @Override
    public Result<PageInfo<ProcessStep>> selectList(ProcessStep processStep, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProcessStep> processSteps=processStepMapper.selectList(processStep);
        return Result.success(new PageInfo<>(processSteps));
    }

    @Override
    public Result<ProcessStep> selectById(Long id) {
        return Result.success(processStepMapper.selectById(id));
    }

    @Override
    public Result<ProcessStep> saveProcessStep(ProcessStep processStep) {
        return processStepMapper.saveProcessStep(processStep)==1?Result.success(processStep):Result.error("操作失败");
    }

    @Override
    public Result<ProcessStep> updateById(ProcessStep processStep) {
        return processStepMapper.updateById(processStep)==1?Result.success():Result.error("操作失败");
    }

    @Override
    public Result deleteById(Long id) {
        return processStepMapper.deleteById(id)==1?Result.success():Result.error("操作失败");
    }
}
